public class EscapeCharHandler implements StateHandler {
    private final StateMachine stateMachine;

    public EscapeCharHandler(StateMachine stateMachine) {
        this.stateMachine = stateMachine;
    }

    @Override
    public void handleChar(char ch, StringBuilder currentString, StateMachine stateMachine) {
        switch (ch) {
            case 'n':
                currentString.append('\n');
                break;
            case 't':
                currentString.append('\t');
                break;
            default:
                currentString.append(ch);
                break;
        }
        stateMachine.setState(State.IN_STRING);
    }
}